package com.example.chatweb.utils;


import com.example.chatweb.entity.UserInfo;
import org.springframework.util.DigestUtils;

import java.util.UUID;

public class MD5PassordUtil {
    public static UserInfo md5(String src, UserInfo user) {
        String salt = UUID.randomUUID().toString().substring(0, 8);
        user.setSalt(salt);
        user.setPassword(DigestUtils.md5DigestAsHex((src + salt).getBytes()));
        return user;
    }
}
